package com.tsc.springTemp.exception;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: chentl
 * @Date: 2025/09/14/10:54
 * @Description:
 */
public class UserService {

    public User findById(int id) throws UserNotFoundException {
        if (id > 100){
            throw new UserNotFoundException("用户不存在");
        }
        return new User(id, "张三");
    }

    public void validateAge(int age){
        if (age < 0 || age > 120){
            throw new InvalidAgeException("年龄不合法: "+ age);
        }
    }
}
